package com.example.administrator.kotlin.adapter

import android.widget.ImageView
import android.widget.LinearLayout
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.example.administrator.kotlin.R
import com.example.administrator.kotlin.bean.Newslist
import com.orhanobut.logger.Logger


class StaggerAdapter(item_image: Int, newslist: ArrayList<Newslist>?) : BaseQuickAdapter<Newslist, BaseViewHolder>(item_image, newslist) {

    init {
        var heights = arrayListOf<Int>()
        for (i in 1..10) {
            heights.add((Math.random() * 300 + 400).toInt())
        }
        Logger.i("tag" + heights.toString())
    }

    override fun convert(holder: BaseViewHolder, item: Newslist) {
        Glide.with(mContext)
                .load(item.picUrl)
                .into(holder.getView(R.id.iv_stagger_pic))

        val layoutParams = holder.getView<ImageView>(R.id.iv_stagger_pic).layoutParams
        layoutParams.height = (Math.random() * 300 + 400).toInt()
        holder.getView<ImageView>(R.id.iv_stagger_pic).layoutParams = layoutParams
    }
}